#ifndef MDTX_USE_RCPPARMADILLO
#define MDTX_USE_RCPPARMADILLO
#endif

#include <RcppArmadillo.h>
using namespace Rcpp;

#include "mdtx-online/indicator/indicator_type_s2_zscore.h"
using namespace mdtx::online;

#include "indi_common.h"

using zscore_ = indi1<indicator::zscore>;

//' Zscore
//'
//' @param x Numeric vector
//' @param period Period of rolling window
//' @param m_period Period of smoothing window
//' @param z zscore threshold
//' @param r attenuate factor
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector zscore(NumericVector x, int period, int m_period, double z, double r)
{
    auto c = zscore_::create_t(period, m_period, z, r);
    return zscore_::run_t(c, x);
}

// [[Rcpp::export(rng = false)]]
SEXP zscore_new(int period, int m_period, double z, double r)
{
    return zscore_::create(period, m_period, z, r);
}

// [[Rcpp::export(rng = false)]]
NumericVector zscore_run(SEXP ptr, NumericVector x)
{
    return zscore_::run(ptr, x);
}

using zscore_ew_ = indi1<indicator::zscore_ew>;

//' Zscore, exponentially weighted
//'
//' @param x Numeric vector
//' @param period Period of rolling window
//' @param m_period Period of smoothing window
//' @param z zscore threshold
//' @param r attenuate factor
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector zscore_ew(NumericVector x, int period, int m_period, double z, double r)
{
    auto c = zscore_ew_::create_t(period, m_period, z, r);
    return zscore_ew_::run_t(c, x);
}

// [[Rcpp::export(rng = false)]]
SEXP zscore_ew_new(int period, int m_period, double z, double r)
{
    return zscore_ew_::create(period, m_period, z, r);
}

// [[Rcpp::export(rng = false)]]
NumericVector zscore_ew_run(SEXP ptr, NumericVector x)
{
    return zscore_ew_::run(ptr, x);
}

using zscore_cu_ = indi1<indicator::zscore_cu>;

//' Cumulative zscore
//'
//' @param x Numeric vector
//' @param m_period Period of smoothing window
//' @param z zscore threshold
//' @param r attenuate factor
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector zscore_cu(NumericVector x, int m_period, double z, double r)
{
    auto c = zscore_cu_::create_t(m_period, z, r);
    return zscore_cu_::run_t(c, x);
}

// [[Rcpp::export(rng = false)]]
SEXP zscore_cu_new(int m_period, double z, double r)
{
    return zscore_cu_::create(m_period, z, r);
}

// [[Rcpp::export(rng = false)]]
NumericVector zscore_cu_run(SEXP ptr, NumericVector x)
{
    return zscore_cu_::run(ptr, x);
}

using stdz_ = indi1<indicator::stdz>;

//' Standard zscore
//'
//' @param x Numeric vector
//' @param period Period of rolling window
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector stdz(NumericVector x, int period)
{
    auto c = stdz_::create_t(period);
    return stdz_::run_t(c, x);
}

// [[Rcpp::export(rng = false)]]
SEXP stdz_new(int period)
{
    return stdz_::create(period);
}

// [[Rcpp::export(rng = false)]]
NumericVector stdz_run(SEXP ptr, NumericVector x)
{
    return stdz_::run(ptr, x);
}

using stdz_ew_ = indi1<indicator::stdz_ew>;

//' Standard zscore, exponential weight
//'
//' @param x Numeric vector
//' @param period Period of rolling window
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector stdz_ew(NumericVector x, int period)
{
    auto c = stdz_ew_::create_t(period);
    return stdz_ew_::run_t(c, x);
}

// [[Rcpp::export(rng = false)]]
SEXP stdz_ew_new(int period)
{
    return stdz_ew_::create(period);
}

// [[Rcpp::export(rng = false)]]
NumericVector stdz_ew_run(SEXP ptr, NumericVector x)
{
    return stdz_ew_::run(ptr, x);
}

using stdz_cu_ = indi1<indicator::stdz_cu>;

//' Cumulative standard zscore
//'
//' @param x Numeric vector
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector stdz_cu(NumericVector x)
{
    auto c = stdz_cu_::create_t();
    return stdz_cu_::run_t(c, x);
}

// [[Rcpp::export(rng = false)]]
SEXP stdz_cu_new()
{
    return stdz_cu_::create();
}

// [[Rcpp::export(rng = false)]]
NumericVector stdz_cu_run(SEXP ptr, NumericVector x)
{
    return stdz_cu_::run(ptr, x);
}

using stdz_vw_ = indi1<indicator::stdz_vw>;

//' Volume weighted standard zscore
//'
//' @param price Numeric vector of price
//' @param volume Numeric vector of volume
//' @param period Period of rolling window
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector stdz_vw(NumericVector price, NumericVector volume, int period)
{
    auto c = stdz_vw_::create_t(period);
    return stdz_vw_::run_t(c, price, volume);
}

// [[Rcpp::export(rng = false)]]
SEXP stdz_vw_new(int period)
{
    return stdz_vw_::create(period);
}

// [[Rcpp::export(rng = false)]]
NumericVector stdz_vw_run(SEXP ptr, NumericVector price, NumericVector volume)
{
    return stdz_vw_::run(ptr, price, volume);
}

using stdz_cuvw_ = indi1<indicator::stdz_cuvw>;

//' Cumulative volume weighted standard zscore
//'
//' @param price Numeric vector of price
//' @param volume Numeric vector of volume
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector stdz_cuvw(NumericVector price, NumericVector volume)
{
    auto c = stdz_cuvw_::create_t();
    return stdz_cuvw_::run_t(c, price, volume);
}

// [[Rcpp::export(rng = false)]]
SEXP stdz_cuvw_new()
{
    return stdz_cuvw_::create();
}

// [[Rcpp::export(rng = false)]]
NumericVector stdz_cuvw_run(SEXP ptr, NumericVector price, NumericVector volume)
{
    return stdz_cuvw_::run(ptr, price, volume);
}

using cci_ = indi1<indicator::cci>;

//' Commodity channel index
//'
//' @param x Numeric vector
//' @param period Period of rolling window
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector cci(NumericVector x, int period)
{
    auto c = cci_::create_t(period);
    return cci_::run_t(c, x);
}

// [[Rcpp::export(rng = false)]]
SEXP cci_new(int period)
{
    return cci_::create(period);
}

// [[Rcpp::export(rng = false)]]
NumericVector cci_run(SEXP ptr, NumericVector x)
{
    return cci_::run(ptr, x);
}
